package xpn.business.fund_return.entity.notice_stub;

import org.springframework.context.ApplicationContextException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class NoticeStubService {
    @Resource
    private NoticeStubDao noticeStubDao;

//    @Resource
//    private FrCaseService frCaseService;

    public NoticeStub save(NoticeStub noticeStub) {
        if (Objects.isNull(noticeStub.getId())) {
            NoticeStub exist = noticeStubDao.findAllByCaseId(noticeStub.getCaseId());
            if (Objects.nonNull(exist)) {
                throw new ApplicationContextException("该表单已存在，请勿重复创建");
            }
        }
//        frCaseService.changeWriteStatus(noticeStub.getCaseId(), CaseWriteStatus.NoticeStub);
        return noticeStubDao.save(noticeStub);
    }
}
